using System;
using System.Collections.Generic;
using System.Text;

namespace Demo3Layer
{
    public class CPhanSoInfo
    {
        private int _tu;
        private int _mau;

        public CPhanSoInfo()
        {
        }
        public CPhanSoInfo(int tu, int mau)
        {
            _tu = tu;
            _mau = mau;
        }
        public int tu
        {
            get
            {
                return _tu;
            }
            set
            {
                _tu = value;
            }
        }

        public int mau
        {
            get
            {
                return _mau;
            }
            set
            {
                _mau = value;
            }
        }

        private int USCLN(int a, int b)
        {
            a = Math.Abs(a); // lay tri tuyet doi cua a
            b = Math.Abs(b); // lay tri tuyet doi cua b
            if (a == 0 || b == 0)
                return 1;
            while (a != b)
            {
                if (a > b)
                    a = a - b;
                else
                    b = b - a;                
            }
            return a;
        }

        public void RutGon()
        {
            int a = USCLN(_mau, _tu);
            _mau /= a;
            _tu /= a;           
        }

        public override string ToString()
        {
            return _tu.ToString() + "/" + _mau.ToString();
        }

       
    }
}
